package MyOop03;

public class GirlTest {
    public static void main(String[] args) {
        //定义数组
        Girl[] b = new Girl[4];
        //创建对象
        Girl girl1 = new Girl("小思思",18,"萌妹子","干饭");
        Girl girl2 = new Girl("小彤彤",19,"甜妹子","玩游戏");
        Girl girl3 = new Girl("小天天",20,"憨妹子","逛街");
        Girl girl4 = new Girl("小佳佳",22,"傻妹子","干活");

        b[0] = girl1;
        b[1] = girl2;
        b[2] = girl3;
        b[3] = girl4;
        //求和
        int sum = 0;
        for (int i = 0; i < b.length; i++) {
            Girl girl = b[i];
            sum = sum + girl.getAge();
        }
        //平均值
        int avg = sum/ b.length;
        int count = 0;
        //统计年龄比平均值低的女朋友有几个？并把她们的信息打印出来
        for (int i = 0; i < b.length; i++) {
            Girl girl = b[i];
            if (girl.getAge()<avg){
                count++;
                System.out.println(girl.getName()+" ,"+girl.getAge()+" ,"+girl.getGender()+" ,"+girl.getHoppy());
            }

        }
        System.out.println("有"+count+"个");
    }
}
